package com.itheima.health.h5.controller;

import com.itheima.health.entity.QueryPageBean;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.CheckItem;
import com.itheima.health.pojo.Permission;
import com.itheima.health.service.PermissionService;
import com.itheima.health.service.ReportServicve;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


@RestController
@Api(tags = "权限模块管理")
public class PermissionController {

    @Reference
    private PermissionService permissionServicve;


    @GetMapping("permission/findAll")
    public Result findAll() {

        return new Result(permissionServicve.list());
    }

    @PostMapping("permission/findPage")
    public Result findPage(@RequestBody QueryPageBean queryPageBean) {
        Result page = permissionServicve.findPage(queryPageBean);
        return page;
    }

    @PostMapping("permission/add")
    public Result add(@RequestBody Permission permission) {
        Boolean flag = permissionServicve.add(permission);

        return new Result(flag);
    }

    @DeleteMapping("permission/deleteCheckItemById/{id}")
    public Result deleteCheckItemById(@PathVariable("id") int id){
        Boolean flag = permissionServicve.deleteCheckItemById(id);

        return new Result(flag);
    }

}

